package thread;

public class Shop {
    public synchronized void buy(){
        try {
            Thread t = Thread.currentThread();//获取运行buy方法的线程
            System.out.println(t.getName()+":正在挑衣服...");
            Thread.sleep(5000);

            System.out.println(t.getName()+":正在试衣间试衣服...");
            Thread.sleep(5000);

            System.out.println(t.getName()+":结账离开");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
